package site.luojie.demo.controller;

import site.luojie.framework.annotations.CustomController;
import site.luojie.framework.annotations.CustomRequestMapping;
import site.luojie.framework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description: 控制层
 * @Author jie.luo
 * @Create: 2020-05-16 23:44
 **/
@CustomController
@CustomRequestMapping("/demo")
public class DemoController {

    @CustomRequestMapping("/system/time")
    public String getSystemTime(HttpServletRequest request, HttpServletResponse response, String username) {
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        return username + " : " + format;
    }

    @Security({"tomcat", "nginx"})
    @CustomRequestMapping("/system/time-all")
    public String getSystemTimeAll(HttpServletRequest request, HttpServletResponse response, String username) {
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        return username + " : " + format;
    }

    @Security({"tomcat"})
    @CustomRequestMapping("/system/time-tomcat")
    public String getSystemTimeTomcat(HttpServletRequest request, HttpServletResponse response, String username) {
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        return username + " : " + format;
    }

    @Security({"nginx"})
    @CustomRequestMapping("/system/time-nginx")
    public String getSystemTimeNginx(HttpServletRequest request, HttpServletResponse response, String username) {
        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        return username + " : " + format;
    }

}

